﻿using Appliaction.Dto.Base_Manage;
using Appliaction.IAppServices.Base_Manage;
using Domain.Entitys.Base_Manage;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    //[Authorize]
    public class DictController : ControllerBase
    {
        private readonly IDictService dictService;
        private readonly IDictdataService dictdataService;
        private readonly IDicttypeService dicttypeService;

        public DictController(IDictService dictService, IDictdataService dictdataService, IDicttypeService dicttypeService)
        {
            this.dictService = dictService;
            this.dictdataService = dictdataService;
            this.dicttypeService = dicttypeService;
        }
        #region Dicttype控制器
        /// <summary>
        /// TYPE查询总条数
        /// </summary>
        /// <param name="Dict_name"></param>
        /// <param name="Dict_type"></param>
        /// <param name="Status"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public JsonResult Getsys_Dict_TypesCount(string? Dict_name, string? Dict_type, char Status)
        {
            return new JsonResult(dicttypeService.Getsys_Dict_TypesCount(Dict_name, Dict_type, Status));
        }
        /// <summary>
        /// TYPE分页查询、条件查询
        /// </summary>
        /// <param name="Dict_name"></param>
        /// <param name="Dict_type"></param>
        /// <param name="Status"></param>
        /// <param name="currentPage"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public JsonResult Getsys_Dict_TypesFyWhere(string? Dict_name, string? Dict_type, char Status, int currentPage, int pageSize)
        {
            return new JsonResult(dicttypeService.Getsys_Dict_TypesFyWhere(Dict_name, Dict_type, Status, currentPage, pageSize));
        }
        /// <summary>
        /// TYPE添加
        /// </summary>
        /// <param name="AddDto"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<IActionResult> Postsys_Dict_TypesAdd(DictTypesAddDto AddDto)
        {
            var result = await dicttypeService.Postsys_Dict_TypesAdd(AddDto);
            return Ok(result);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="DeleteDto"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPut]
        public async Task<IActionResult> Putsys_Dict_TypesDelete(DictTypesDeleteDto DeleteDto)
        {
            var result = await dicttypeService.Putsys_Dict_TypesDelete(DeleteDto);
            return Ok(result);
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="UpdateDto"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPut]
        public async Task<IActionResult> Putsys_Dict_TypesUpdate(DictTypesUpdateDto UpdateDto)
        {
            var result = await dicttypeService.Putsys_Dict_TypesUpdate(UpdateDto);
            return Ok(result);
        }
        #endregion

        #region Dictdata控制器
        /// <summary>
        /// 查询总条数
        /// </summary>
        /// <param name="Dict_type"></param>
        /// <param name="Dict_label"></param>
        /// <param name="Status"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public JsonResult Getsys_Dict_DatasCount(string? Dict_type, string? Dict_label, char Status)
        {
            return new JsonResult(dictdataService.Getsys_Dict_DatasCount(Dict_type, Dict_label, Status));
        }
        /// <summary>
        /// 分页查询、条件查询
        /// </summary>
        /// <param name="Dict_type"></param>
        /// <param name="Dict_label"></param>
        /// <param name="Status"></param>
        /// <param name="currentPage"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public JsonResult Getsys_Dict_DatasWhere(string? Dict_type, string? Dict_label, char Status, int currentPage, int pageSize)
        {
            return new JsonResult(dictdataService.Getsys_Dict_DatasWhere(Dict_type, Dict_label, Status, currentPage, pageSize));
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="AddDto"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<IActionResult> Postsys_Dict_DatasAdd(DictdataAddDto AddDto)
        {
            var result = await dictdataService.Postsys_Dict_DatasAdd(AddDto);
            return Ok(result);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="DeleteDto"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPut]
        public async Task<IActionResult> Putsys_Dict_DatasDelete(DictdataDeleteDto DeleteDto)
        {
            var result = await dictdataService.Putsys_Dict_DatasDelete(DeleteDto);
            return Ok(result);
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="UpdateDto"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPut]
        public async Task<IActionResult> Putsys_Dict_DatasUpdate(DictdataUpdateDto UpdateDto)
        {
            var result = await dictdataService.Putsys_Dict_DatasUpdate(UpdateDto);
            return Ok(result);
        }
        #endregion


        /// <summary>
        /// 根据字典类型查询字典数据
        /// </summary>
        /// <param name="dict_type"></param>
        /// <returns></returns>
        [HttpGet]
        public JsonResult Get_Dict_Datas(string dict_type)
        {
            return new JsonResult(dictService.Get_Dict_Datas(dict_type));
        }
    }
}
